package 简单的策略模式.计算器;

import 简单的工厂模式.工厂模式demo.计算器.Add;
import 简单的工厂模式.工厂模式demo.计算器.Div;
import 简单的工厂模式.工厂模式demo.计算器.Mul;
import 简单的工厂模式.工厂模式demo.计算器.Operation;
import 简单的工厂模式.工厂模式demo.计算器.Sub;

/**
 * @author zyl
 * @Description
 * @since 2023/12/27 14:38
 */

public class OperationContext {

    Operation operation = null;
    public OperationContext(String operator){
        switch (operator){
            case "+":
                operation = new Add();
                break;
            case "-":
                operation = new Sub();
                break;
            case "*":
                operation = new Mul();
                break;
            case "/":
                operation = new Div();
                break;

        }
    }
    protected Double getResult(double numberA, double numberB){
        return this.operation.getResult(numberA,numberB);
    }
}
